
ConstantContact::Activity.class_eval do
  protected
    def encoded_data
      result = "&data="
      if self.raw_data.nil?
        result += CGI.escape("Email Address,First Name,Last Name, COMPANY NAME,STATE,CUSTOM FIELD 1, CUSTOM FIELD 2, CUSTOM FIELD 3, CUSTOM FIELD 4\n")
        contact_strings = []
        self.contacts.each do |contact|
          contact_strings << "#{contact.email_address}, #{contact.first_name}, #{contact.last_name}, #{contact.company_name},#{contact.state_code},#{contact.custom_field1},#{contact.custom_field2},#{contact.custom_field3},#{contact.custom_field4}"
        end
        result += CGI.escape(contact_strings.join("\n"))
      else
        result += CGI.escape(self.raw_data)
      end
      return result
    end
end
